#include <stdio.h>
#include <windows.h>

int Inc( int count, int& start, int& finish )
{
	int inc = 0;

	start = GetTickCount();

	for(int i = 0; i < count; i++)
		inc++;

	finish = GetTickCount();

	return inc;
}

int NoSynchInc( int count, int& start, int& finish )
{
	int inc = 0;

	start = GetTickCount();

#pragma omp parallel for
	for(int i = 0; i < count; i++)
		inc++;

	finish = GetTickCount();

	return inc;
}

int SynchInc( int count, int& start, int& finish )
{
	int inc = 0;

	start = GetTickCount();

#pragma omp parallel for
	for(int i = 0; i < count; i++)
	{
#pragma omp atomic
		inc++;
	}

	finish = GetTickCount();

	return inc;
}

int main()
{
	int start, finish;

	int count = 800000000;

	start = finish = 0;

	int res = Inc(count, start, finish);
	int time = finish - start;

	printf( "Result without paralleling : %d at time of %d\n", res, time );

	res = NoSynchInc(count, start, finish);
	time = finish - start;

	printf( "Result without synchronisation : %d at time of %d\n", res, time );

	res = SynchInc(count, start, finish);
	time = finish - start;

	printf( "Result with synchronisation : %d at time of %d\n", res, time );

	return 0;
}